import java.util.*;

/**
 * @author LKQ
 * @date 2022/3/15 9:04
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {3,2,1,5};
        solution.countMaxOrSubsets(nums);
    }
    public int countMaxOrSubsets(int[] nums) {
        int cnt = 0, n = nums.length;
        int maxOr = 0;
        for (int i  = 0; i < 1 << n; i++) {
            int orVal = 0;
            for (int j = 0; j < n; j++) {
                if (((i >> j) & 1) == 1) {
                    orVal |= nums[j];
                }
            }
            if (orVal > maxOr) {
                maxOr = orVal;
                cnt = 1;
            }else if (orVal == maxOr) {
                cnt++;
            }
        }
        return cnt;
    }
}
